#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define close(); std::ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
//----------------------------------------------------------------------------//
int n, s, a, e;
struct stu
{
	int s, a, e;
	ll sum;
	bool operator<(stu& s)
	{
		return sum< s.sum;
	}
}stu[1010];

int main()
{
	close();
	cin >> n;

	for (int i = 1; i <= n; i++)
	{
		cin >> s >> a >> e;
		stu[i].s = s; stu[i].a = a; stu[i].e = e; stu[i].sum = s * 1ll + a * 1ll+e*1ll;
	}

	ll calc = 0,prev=0;
	sort(stu + 1, stu + 1 + n);
	for (int i = 1; i <= n; i++)
	{
		calc += stu[i].sum-stu[i].e+prev;
		prev +=stu[i].sum;
	}
	cout << calc << '\n';
	return 0;
}